package com.example.study.utils;


public class JsonResult<T> {

    private T data;

    private Integer code;

    private String msg;


    /**
     * 若没有数据返回则返回
     * code:0
     * msg:操作成功
     */
    public JsonResult() {
        this.code = 0;
        this.msg = "操作成功";
    }

    /**
     * 若没有数据返回可以指定返回code msg
     * code:code
     * msg:msg
     */
    public JsonResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 若有数据返回则返回data 0 操作成功
     * data:data
     * code:0
     * msg:""
     */
    public JsonResult(T data){
        this.data = data;
        this.code = 0;
        this.msg = "操作成功";
    }

    /**
     * 若有数据返回则返回data 0 人为指定信息
     */
    public JsonResult(T data,String msg){
        this.data = data;
        this.code = 0;
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
